Breaking Shape Contours
Polygon and path shapes can contain many contours. Each contour of a polygon shape can be made up of many lines and each contour of a path shape can be made up of many lines and curves.QuickDraw GX provides a method for breaking a single contour of a polygon or path shape into two contours at a specified geometric point in the original contour.
As an example, the sample function in Listing 4-2 creates a path shape with a single contour. This contour contains six geometric points and is made up of a curve, a line, and another curve.
Listing 4-2 Creating a path shape with a single contour
void CreateSingleContourPath(void) { gxShape aPathShape; static long oneContourGeometry[] = {1, /* number of contours */ 6, /* number of points */ 0x48000000, /* 0100 1000 */ ff(100), ff(150), /* on */ ff(50), ff(100), /* off */ ff(100), ff(50), /* on */ ff(200), ff(50), /* on */ ff(250), ff(100), /* off */ ff(200), ff(150)};/* on */ aPathShape = GXNewPaths((gxPaths *) oneContourGeometry); GXSetShapeFill(aPathShape, gxClosedFrameFill); GXDrawShape(aPathShape); GXDisposeShape(aPathShape); }The result of this function is shown in Figure 4-20.Figure 4-20 A path shape with a single contour
The
GXBreakShape
function allows you to break a single contour into two contours at a specified geometric point. Adding the function call
GXBreakShape(aPathShape, 4);to the sample function in Listing 4-2 breaks the single contour of the path shape into two contours at the fourth geometric point, as shown in Figure 4-21.Figure 4-21 A path shape broken into two contours
After the call to the
GXBreakShape
function, the path shape has two contours, each with three geometric points. Calling the function
GXCountShapeContours(aPathShape);returns the value 2.In addition to breaking the contours of polygon and path shapes, you can also use the
GXBreakShape
function to break line shapes and curve shapes. For example, if the variableaLine
references a line shape, the function call
GXBreakShape(aLine, 1);converts the line shape to a polygon shape with two contours. The first contour is empty (that is, it has no geometric points) and the second contour is the original line. Calling the function
GXCountShapeContours(aLine);returns the value 2.For a discussion of contours, geometric points, and the
GXCountShapeContours
function, see Chapter 2, "Geometric Shapes," in this book.You can also use the
GXSetPolygonParts
,GXSetPathParts
, andGXSetShapeParts
functions to break a shape's contours. These functions are also described in Chapter 2, "Geometric Shapes," in this book.For more information about the
GXBreakShape
function, see page 4-72.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help